/*
 * ******************************************************************************
 * Class: LinkedList	
 * 
 * @author: Teresa Mafalda dos Reis Frazao
 * @version:April 10, 2014 
 * 
 * Class used for misc operations with List structures.
 * ******************************************************************************
 */
package com.feedzai.service.utils;



import java.util.LinkedList;

import com.feedzai.service.data.ServiceNode;

public class ListUtils {
	
	
	/*
	 * ---------------------------------------------------------------------------
	 * 							Public Interface 
	 * ---------------------------------------------------------------------------
	 */
	
	/**
	 * Reverse a linked list.
	 *
	 * @param list the list
	 * @return the linked list
	 */
	public LinkedList<ServiceNode> reverseLinkedList(LinkedList<ServiceNode> list)
	{
		LinkedList<ServiceNode> reverseList = new LinkedList<ServiceNode>();
		
	    if (list == null) 
	    {
	    	return reverseList; 
	    }

	    if (list.isEmpty()) 
	    {
	    	return reverseList; 
	    }
	    
	    for(int i=list.size()-1; i>0; i--)
	    {
	    	reverseList.add(list.get(i));
	    }

	    return reverseList;
	}

}
